<template>
  <!--页头导航
  title:页面标题
  butsData:4级导航名（数组）
  active:默认显示页面(数组下标)
  -->
  <el-card :body-style="{ padding: '0px', height: '100%', width: '100%'}" class="box-card" shadow="never">
    <span class="title">{{ title }}</span>
    <div v-if="butsData.length > 0" class="tabs">
      <div
        v-for="(itme, i) in butsData"
        :key="i"
        :class="{ tabsActive: active === i }"
        @click="backToHome()">
        <a href="javascript:void(0)">{{ itme.name }}</a>
      </div>
    </div>
  </el-card>
</template>

<script>
export default {
  name: 'FourMenu',
  props: {
    showIndex: {
      type: Number,
      default: 0
    },
    title: {
      type: String,
      default: ''
    },
    butsData: {
      type: Array
    }
  },
  data () {
    return {
      active: 0
    }
  },
  watch: {
    showIndex (newVal, oldVal) {
      this.active = newVal
    }
  },
  // computed: {
  //   active() {
  //     return this.showIndex
  //   }
  // },
  methods: {
    setIndex (i) {
      this.active = i
    },
    backToHome () {
      this.$router.go(-1)
    }
  }
}
</script>

<style scoped>
.box-card {
  border-radius: 10px;
  box-shadow: 0px 0px 6px rgba(0, 0, 0, 0.1);
}
.title {
  height: 18px;
  color: #333333;
  font-size: 18px;
  font-weight: 700;
  line-height: 50px;
  margin-left: 20px;
}
.tabs {
  height: 42px;
  line-height: 40px;
  border: 1px solid #cdd5e1;
  border-radius: 20px;
  float: right;
  margin: 5px 10px 5px auto;
}
.tabs div {
  height: 30px;
  float: left;
  padding-left: 20px;
  padding-right: 20px;
  margin: 5px 5px;
  text-align: center;
  line-height: 30px;
  border-radius: 15px;
}
.tabs div a {
  text-decoration: none;
  display: block;
  font-size: 16px;
  color: #666666;
}
.tabsActive {
  background-color: #2f85f0;
  box-shadow: 2.83px 2.83px 7px rgba(47, 133, 240, 0.2);
}
.tabsActive>:first-child{
    color: #fff;
}
</style>
